From 90073f35238082976573e5d6bc4e681bec20e30c Mon Sep 17 00:00:00 2001
From: Leah Neukirchen <leah@vuxu.org>
Date: Thu, 27 Jan 2022 14:53:15 +0100
Subject: [PATCH] sig_atomic_t should be used with volatile

---
 snooze.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/snooze.c b/snooze.c
index ed929c7..06f0d07 100644
--- a/snooze.c
+++ b/snooze.c
@@ -31,7 +31,7 @@ static int randdelay = 0;
 static int jitter = 0;
 static char *timefile;
 
-static sig_atomic_t alarm_rang = 0;
+static volatile sig_atomic_t alarm_rang = 0;
 
 static void
 wakeup(int sig)
@@ -356,11 +356,11 @@ main(int argc, char *argv[])
 		printf("Snoozing until %s\n", isotime(tm));
 
 	// setup SIGALRM handler to force early execution
-	struct sigaction sa;
+	struct sigaction sa = { 0 };
 	sa.sa_handler = &wakeup;
 	sa.sa_flags = SA_RESTART;
 	sigfillset(&sa.sa_mask);
-	sigaction(SIGALRM, &sa, NULL);  // XXX error handling
+	sigaction(SIGALRM, &sa, NULL);
 
 	while (!alarm_rang) {
 		now = time(0);
